{include file="public/adminhead"}

<div class="container-fluid">

  <div class="row">
    <div class="card">
      <div class="card-body">

        <form class="form-horizontal" action="#" method="post" enctype="multipart/form-data" onsubmit="return false;">


          <div class="form-group">
            <label class="col-xs-12">父级菜单</label>
            <div class="col-xs-12">
              {if !$res}
              <select class="form-control" name="pid" size="1">
                <option value="0">请选择</option>
                {foreach $tmenu as $k => $v}
                <option value="{$v.id}" {if $v.checked == '1'}selected{/if}>{$v.name}</option>
                    {if $v.children}
                        {foreach $v.children as $n}
                        <option value="{$n.id}" {if $n.checked == '1'}selected{/if}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$n.name}</option>
                              {if $n.children}
                              {foreach $n.children as $k}
                              <option value="{$k.id}" {if $k.checked == '1'}selected{/if}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$k.name}</option>
                              {/foreach}
                              {/if}
                        {/foreach}
                    {/if}
                {/foreach}
              </select>
              {else /}
              <input type="hidden" name="id" value="{$res.id}">
              <select class="form-control" name="pid" size="1">
                <option value="0">请选择</option>
                {foreach $menu as $k => $v}
                  <option value="{$v.id}" {if $res.pid == $v.id}selected{/if}>{$v.name}</option>
                    {if $v.children}
                    {foreach $v.children as $n}
                      <option value="{$n.id}" {if $res.pid == $n.id}selected{/if}>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$n.name}</option>
                    {/foreach}
                    {/if}
                {/foreach}
              </select>
              {/if}


            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >菜单名称</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.name}"{/if} name="name" placeholder="..">
              <div class="help-block">如:常用操作</div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >控制器名</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.module_name}"{/if} name="module_name" placeholder="controller..">
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >方法名</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.action_name}"{/if} name="action_name" placeholder="action..">
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >图标</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.icon}"{/if} name="icon" placeholder="如:mdi-comment-check..">
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >附加数据</label>
            <div class="col-xs-12">
              <input class="form-control" type="text" {if $res}value="{$res.data}"{/if} name="data" placeholder="如:?id=1&name=ss&age=6">
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >排序值</label>
            <div class="col-xs-12">
              <input class="form-control"  {if $res}value="{$res.ordid}"{/if} type="text" name="ordid" placeholder="默认255">
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12" >文本域</label>
            <div class="col-xs-12">
              <textarea class="form-control" name="remark" rows="6" placeholder="内容..">{if $res}{$res.remark}{/if} </textarea>
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12">是否显示</label>
            <div class="col-xs-12">
              <div class="radio">
                <label>
                  <input type="radio" name="display" value="1" {if $res}{if $res.display==1}checked="checked"{/if}{/if}>
                  是
                </label>
              </div>
              <div class="radio">
                <label >
                  <input type="radio" name="display" value="0" {if $res}{if $res.display==0}checked="checked"{/if}{/if} >
                  否
                </label>
              </div>
            </div>
          </div>

          <div class="form-group">
            <label class="col-xs-12">是否是常用操作</label>
            <div class="col-xs-12">
              <div class="radio">
                <label>
                  <input type="radio" name="often" value="1" {if $res}{if $res.often==1}checked="checked"{/if}{/if}>
                  是
                </label>
              </div>
              <div class="radio">
                <label >
                  <input type="radio" name="often" value="0" {if $res}{if $res.often==0}checked="checked"{/if}{/if} >
                  否
                </label>
              </div>
            </div>
          </div>

          <div class="form-group">
            <div class="col-xs-12">
              <button class="btn btn-primary" type="button" onclick="sub()">提交</button>
            </div>
          </div>
        </form>

      </div>
    </div>
  </div>

</div>

{include file="public/afooter"}

<script>
function sub() {
    var formdata = $("form").serialize();
    var url = "{:url('AdminRbac/add')}";
    $.post(url,formdata,function (e) {
      if(e.code == 200){
          success("成功");
          var index = parent.layer.getFrameIndex(window.name);
          setTimeout(function(){parent.layer.close(index)}, 2000);
          window.parent.location.reload();
      }else {
          error("失败");
      }
    })
}
</script>